package com.jdrx.sw.sewage.service;

import com.jdrx.sw.sewage.beans.entity.MaterielPO;
import com.jdrx.sw.sewage.beans.vo.MaterielVO;
import com.jdrx.sw.sewage.dao.MaterielDAO;
import com.jdrx.sw.sewage.service.base.BaseServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MaterielServiceImpl extends BaseServiceImpl {

    public static final Logger logger = LoggerFactory.getLogger(MaterielServiceImpl.class);

    @Autowired
    private MaterielDAO materielDAO;
    @Autowired
    private CategoryServiceImpl categoryServiceImpl;

    public List<MaterielVO> selectMaterielAndDevStorage() {
        List<MaterielVO> materielVOS = this.selectList();
        materielVOS.forEach(item -> {
            item.setDevStorageNames(categoryServiceImpl.selectNameList(item.getId()));
        });
        return materielVOS;
    }

    public List<MaterielVO> selectList() {
        return materielDAO.selectList();
    }

    public List<String> selectName() {
        return materielDAO.selectNameList();
    }

    public void addMateriel(String name) {
        MaterielPO materielPO = new MaterielPO();
        materielPO.setAlarmTypeId(112L);//暂时写死吧
        materielPO.setName(name);
        materielDAO.insert(materielPO);
    }
}
